#!/us/bin/env  node

const koa=require('koa');
const app=new koa(),
      log=console.log;


console.log('hello wangyibo');






app.use(async (ctx,next)=>{//m-logger
  log(`${ctx.method} ${ctx.path}  `);

   //let cost=await  next();
   next();
  log(`cost:${ctx.cost}ms`);

})



app.use((ctx,next)=>{//m-ms
  const start=Date.now();
 
  
  next();
  const end=Date.now();
  ctx.cost=end-start;
 // return end-start; 
 // ctx.set('cost',end-start);
  })




app.use((ctx,next)=>{//m.hello


  ctx.body='hello koa';

})


app.listen(8080);
